package design_pattern.observer.demo01;

/**
 * @version 1.0.0
 * Created by cyd on 2022-06-15 17:17:03
 * @ClassName : design_pattern.observer.demo01.Example03
 * @Description : 类描述
 */
public class Main {
    public static void main(String[] args) {
        ConcreteSubject concreteSubject = new ConcreteSubject();
        concreteSubject.attach(new ConcreteObserver("01", concreteSubject));
        concreteSubject.attach(new ConcreteObserver("02", concreteSubject));
        ConcreteObserver concreteObserver03 = new ConcreteObserver("03", concreteSubject);
        concreteSubject.attach(concreteObserver03);

        concreteSubject.setSubjectState("on");
        concreteSubject.notifyObserver();

        concreteSubject.setSubjectState("off");
        concreteSubject.notifyObserver();

        concreteSubject.detach(concreteObserver03);
        concreteSubject.setSubjectState("on");
        concreteSubject.notifyObserver();

    }
}
